<template>
  <view>
    <web-view :webview-styles="webviewStyles" :src="url"></web-view>
  </view>
</template>

<script>
import {
  mapGetters,
  mapActions
} from 'vuex'
import Config from "../../api/Config";

export default {
  data() {
    return {
      webviewStyles: {
        progress: {
          color: '#FF3333'
        }
      },
      id: "",
      fileName: "",
      url: "",
      fileType: ""
    }
  },
  computed: {
    ...mapGetters([ 'userInfo' ])
  },
  onLoad(option) {
    this.id = option.id;
    this.fileName = option.fileName;
    this.fileType = option.fileType;
    if (this.fileType == "office_type") {
      let file_url = "/mobile/downFile_to_pdf.action?userNo=" + this.userInfo.userModel.userNo + "&sessionId=" + this.userInfo.sessionId + "&accId=" + this.id + "&&fileName=" + this.fileName
      let urlSrc = Config.BASE_URL + "/res/generic/web/viewer.html?file=" + encodeURIComponent(file_url);
      this.url = urlSrc;
    } else if (this.fileType == "img_type") {
      let file_url = Config.BASE_URL + "/img_preview.jsp?userNo=" + this.userInfo.userModel.userNo + "&sessionId=" + encodeURIComponent(this.userInfo.sessionId) + "&id=" + this.id + "&&fileName=" + this.fileName
      this.url = file_url;
    }

  }
}
</script>

<style>

</style>
